import { Swiper } from 'antd-mobile';
import React, { Component } from 'react';
import { banner_list } from "../../../api/index";
import '../../../styles/index/Home/Swiper.scss'

class Swipers extends Component {
  async componentDidMount() {
    var res = await banner_list()
    // console.log(res.data);
    if (res.data.code == 200) {
      this.setState({ list: res.data.data })
    }
  }
  constructor(props) {
    super(props)
    this.state = {
      list: []
    }
  }
  render() {
    return (
      <div className='swiper'>
        <Swiper autoplay>
          {
            this.state.list.map((item, index) => {
              return (
                <Swiper.Item key={index}>
                  <div>
                    <img src={item.img} alt="" />
                  </div>
                </Swiper.Item>
              )
            })
          }
        </Swiper>
      </div>
    );
  }
}

export default Swipers;